import http from '@/utils/http'

const BASE_URL = '/system/scheduleJobLog'

export interface ScheduleJobLogResp {
  id: string
  jobId: string
  jobName: string
  cron: string
  paramJson: string
  startTime: string
  endTime: string
  elapsedSeconds: string
  runStatus: string
  dataCount: string
  resultMessage: string
}

export interface ScheduleJobLogDetailResp extends ScheduleJobLogResp {
}

export interface ScheduleJobLogQuery extends SortQuery {
  jobName?: string
  runStatus?: string
}

export interface ScheduleJobLogPageQuery extends ScheduleJobLogQuery, PageQuery {

}

/** @desc 查询定时任务日志列表 */
export function getPage(query: ScheduleJobLogPageQuery) {
  return http.get<Page<ScheduleJobLogResp[]>>(`${BASE_URL}/page`, query)
}

/** @desc 查询定时任务日志详情 */
export function getDetail(id: string) {
  return http.get<ScheduleJobLogDetailResp>(`${BASE_URL}/detail/${id}`)
}

/** @desc 创建定时任务日志 */
export function create(data: any) {
  return http.post(`${BASE_URL}/create`, data)
}

/** @desc 修改定时任务日志 */
export function update(data: any, id: string) {
  return http.post(`${BASE_URL}/update/${id}`, data)
}

/** @desc 删除定时任务日志 */
export function remove(ids: string | Array<string>) {
  return http.post(`${BASE_URL}/delete/${ids}`)
}
